<?php

namespace App\Models\Open;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Dcat\Admin\Traits\ModelTree;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Spatie\EloquentSortable\Sortable;

class SysAccountMenu extends Model implements Sortable
{
	use HasDateTimeFormatter;
    use SoftDeletes;
    use ModelTree;

    protected $sortable = [
        'sort_when_creating' => true,
    ];

    protected $table = 'sys_account_menus';

    protected $fillable = [
        'sys_account_id', 'parent_id', 'order', 'title', 'type', 'url', 'appid', 'pagepath', 'key',
    ];

    public function childs() : HasMany
    {
        return $this->hasMany(SysAccountMenu::class, 'parent_id');
    }

}
